package com.rhb.cg.distribute;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


public class DistributeDefinition {
	public static Map prase(File file) {
		SAXReader reader = new SAXReader();
		Map mergeMap = new HashMap();
		try {
			Document doc = reader.read(file);
			Element root = doc.getRootElement();
			for (Iterator i = root.elementIterator(); i.hasNext();) {
				Element e = (Element) i.next();
				String fileName = e.attribute("name").getValue();
				String beanid = e.attribute("merge-context-bean-id").getValue();
				//setAttribute(screen, e);
				mergeMap.put(fileName, beanid);
			}
			//System.out.println(screens);
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return mergeMap;
	}
}
